package t.yatush.core_infra_svc;

import java.io.File;
import java.io.FileNotFoundException;
import java.io.FileReader;
import java.io.IOException;
import java.sql.PreparedStatement;
import java.sql.SQLException;

import org.apache.commons.io.IOUtils;

public class ScriptEngine extends DbSysTool {

	private static ScriptEngine instance;

	public static ScriptEngine getInstance(){
		if(instance == null){
			instance = new ScriptEngine();
		}
		return instance;
	}

	private ScriptEngine() {
		super();
	}

	public void runFileScript(String scriptPath) throws Exception {
		String scriptStr = null;
		scriptStr = IOUtils.toString(new FileReader(scriptPath));
		runStrScript(scriptStr);
	}

	//	public static void main(String[] args) {
	//		System.out.println(new File(".").getAbsoluteFile());
	//		ScriptEngine se = new ScriptEngine();
	//		String scriptStr = "create table t2 (id integer, name varchar);\n"
	//				+ "create table t3 (id integer, name varchar);\n";
	//		// se.runStrScript(scriptStr);
	//		se.runFileScript("target/classes/db/sql/000001-nissima-product_insert_table.sql");
	//	}

}
